package com.scau.clothes.service.impl;

import com.scau.clothes.service.TestService;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestServiceImpl implements TestService {
    @Autowired
    StringRedisTemplate redisTemplate;
    @Autowired
    RabbitTemplate rabbitTemplate;

    @Override
    public void testRabbit() {
        rabbitTemplate.convertAndSend("testQ","test");
    }
    @RabbitListener(queuesToDeclare = @Queue(value = "testQ"))
    private void handle(String msg){
        redisTemplate.opsForValue().set("test1","set");
        System.out.println(msg);
    }
}
